﻿// JScript File
var btnSearch;

function handleEnter (field, event) {
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if (keyCode == 13) {
		var i;
		for (i = 0; i < field.form.elements.length; i++)
			if (field == field.form.elements[i])
				break;
		i = (i + 1) % field.form.elements.length;
		field.form.elements[i].focus();
		return false;
	} 
	else
		return true;
}

function Event_OnKeyPress(ButtonID) {
	btnSearch = window.document.getElementById(ButtonID);
    var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if(keyCode == 13)
		btnSearch.click();
}

function openWindow(sUrl, sWindowName, iWidth, iHeight) {
	if (sUrl == "UNDER_CONSTRUCTION") {
		return alert("This part is under construction.");
	} else {
		var objWin;
		var objOptions;
		//make it locate at center of the page.
		var WidthX = (screen.availWidth/2) - (iWidth/2)
		var HeightY = (screen.availHeight/2) - (iHeight/2)
		objOptions = 'status=no,menubar=no,scrollbars=yes,resizable=no,toolbar=no';
		objOptions = objOptions + ',width=' + iWidth;
		objOptions = objOptions + ',height=' + iHeight;
		objOptions = objOptions + ',left=' + WidthX + ',top=' + HeightY;
		objWin = window.open( '', sWindowName, objOptions );
		
		if (objWin != null) {
		    //set the url.
		    objWin.location = sUrl;
		    //set focus to the popup
		    objWin.focus();
		}
	}
}

function openWindowNoFix(sUrl, sWindowName) {
	if (sUrl == "UNDER_CONSTRUCTION") {
		return alert("This part is under construction.");
	} else {
		var objWin;
		objWin = window.open( '', sWindowName );
		
		if (objWin != null) {
		    //set the url.
		    objWin.location = sUrl;
		    //set focus to the popup
		    objWin.focus();
		}
	}
}

function ShowComment(id){
    url = 'WriteComment.aspx?id=' + id;
    openWindow(url, 'dbtt', 600, 450);
}

function doHideShow(num,divName){
    for (i=0; i<num; i++) {
        var s = 'divpark' + i;
        var obj = document.getElementById(s);
        obj.style.display = 'none';
    }
    var objDiv = document.getElementById(divName);
    if (objDiv != null) {
        objDiv.style.display = '';
    }
}